<template>
  <div id="finance_profit">
    <el-form :inline="true" class="demo-form-inline" size="medium" :disabled="load">
      <el-form-item>
        <el-button type="primary" @click="search">搜索</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="list" stripe style="width: 100%" v-loading="load">
      <el-table-column prop="id" label="id" align="center"></el-table-column>
      <el-table-column label="收益金额" width="140" align="center">
        <template slot-scope="scope">
          <span>{{$common.toThousands(scope.row.money, true)}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="origin" label="收益来源"  align="center"></el-table-column>
      <el-table-column prop="remark" label="备注"  align="center"></el-table-column>
      <el-table-column  label="创建时间" align="center">
        <template slot-scope="scope">
          <span>{{$moment(scope.row.createTime).format('Y-MM-DD HH:mm')}}</span>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      class="page"
      background
      layout="total, prev, pager, next"
      :page-size="requestParam.pageSize"
      :total="total"
      @current-change="getList"
    >
    </el-pagination>
  </div>
</template>

<script>
export default{
  data() {
    return {
      list: [],
      requestParam:{
        startTime: '',
        endTime: '',
        pageSize: 10,
        pageNo: 1,
        tenantid:sessionStorage.getItem("tenantid")
      },
      total: 0,
      load: false,
      date: [],
    };
  },

  created(){
    this.search()
  },

  methods:{
    // 获取列表
    getList(pageNo){
      if(this.load){
        return;
      }
      if(this.date && this.date.length){
        this.requestParam.startTime = this.$moment(this.date[0]).format('Y-MM-DD HH:mm:ss')
        this.requestParam.endTime = this.$moment(this.date[1]).format('Y-MM-DD HH:mm:ss')
      }else{
        this.date = [];
        this.requestParam.startTime = ''
        this.requestParam.endTime = ''
      }
      this.load = true
      this.requestParam.pageNo = pageNo
      this.$request.post({
        url: '/ReportApi/tenant/financeunprofitlist',
        params: this.requestParam,
        success: result=>{
          this.list = result[0]
          if(this.requestParam.isCount){
            this.total = result[1]
          }
        },
        finally: ()=>{
          this.load = false
        }
      })
    },
    
    search(){
      this.requestParam.isCount = true 
      this.getList(1)
    }
  }
}

</script>

<style>
	.page{
		text-align: right;
		margin-top: 20px;
	}
</style>
